﻿using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Actuals.Data
{
    public interface IDalManager
    {
        Database Database { get; }

        string StoredProcedureName { get; set; }
        string SqlStringCommand { get; set; }

        DataSet LoadDataSet(string storedProcedureName, DataSet dataSet, string[] tableNames, params object[] parameterValues);
        DataSet LoadDataSet(DbTransaction transaction, string storedProcedureName, DataSet dataSet, string[] tableNames, params object[] parameterValues);
        DataSet LoadDataSet(CommandType commandType, string commandText, DataSet dataSet, string[] tableNames);
        DataSet LoadDataSet(DbTransaction transaction, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames);
        DataSet LoadDataSet(string tableName);
        DataSet LoadDataSet(string tableName, DbTransaction transaction);
        DataSet LoadDataSet(string[] tableNames);
        DataSet LoadDataSet(string[] tableNames, DbTransaction transaction);
        DataSet LoadDataSet(string storedProcedureName, string[] tableNames, params object[] parameterValues);
        DataSet LoadDataSet(DbTransaction transaction, string storedProcedureName, string[] tableNames, params object[] parameterValues);
        DataSet LoadDataSet(CommandType commandType, string commandText, string[] tableNames);
        DataSet LoadDataSet(DbTransaction transaction, CommandType commandType, string commandText, string[] tableNames);

        DataSet ExecuteDataSet();
        DataSet ExecuteDataSet(DbTransaction transaction);
        DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues);
        DataSet ExecuteDataSet(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);
        DataSet ExecuteDataSet(CommandType commandType, string commandText);
        DataSet ExecuteDataSet(DbTransaction transaction, CommandType commandType, string commandText);

        object ExecuteScalar();
        object ExecuteScalar(DbTransaction transaction);
        object ExecuteScalar(string storedProcedureName, params object[] parameterValues);
        object ExecuteScalar(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);
        object ExecuteScalar(CommandType commandType, string commandText);
        object ExecuteScalar(DbTransaction transaction, CommandType commandType, string commandText);

        int ExecuteNonQuery();
        int ExecuteNonQuery(DbTransaction transaction);
        int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues);
        int ExecuteNonQuery(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);
        int ExecuteNonQuery(CommandType commandType, string commandText);
        int ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string commandText);

        IDataReader ExecuteReader();
        IDataReader ExecuteReader(DbTransaction transaction);
        IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues);
        IDataReader ExecuteReader(DbTransaction transaction, string storedProcedureName, params object[] parameterValues);
        IDataReader ExecuteReader(CommandType commandType, string commandText);
        IDataReader ExecuteReader(DbTransaction transaction, CommandType commandType, string commandText);

        void AddInParameter(string name, DbType dbType, string sourceColumn, DataRowVersion sourceVersion);
        void AddInParameter(string name, DbType dbType, object value);
        void AddInParameter(string name, DbType dbType);
        void AddOutParameter(string name, DbType dbType, int size);
        void AddParameter(string name, DbType dbType, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, object value);
        void AddParameter(string name, DbType dbType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value);

        object GetParameterValue(string s);

        T GetValue<T>(DataRow row, string columnName);

        void BeginTransaction();
        void CommitTransaction();
        void RollbackTransaction();
    }
}
